#include "LoginControl.h"
#include <QDebug>
#include <iostream>
#include <future>
#ifdef WIN32
#else
#include <unistd.h>
#endif
#include "Tool/IM_Core_Slots.h"
#include <QObject>
#include "Control/Init.h"
#include "Tool/TaskTool.h"
#include "PageControl.h"
#include "IM_CoreApi.h"
using namespace IM_GUI_KIT;

struct myLoginData{
  QString user;
  QString password;
  LoginControl *ui;
};

void LoginControl::doLogin(QString user, QString password)
{
  qDebug()<<"user "<<user;
  myLoginData *data=new myLoginData();
  data->user=user;
  data->password=password;
  data->ui=this;
  emit loginDoing();
  TaskTool([](void*userdata){
      qDebug()<<"dasdad1";
#ifdef WIN32
#else
      sleep(0);
#endif
      qDebug()<<((myLoginData*)userdata)->user;
      emit ((myLoginData*)userdata)->ui->loginSuccess();
      qDebug()<<"dasdad2";
      IM_CoreApi::Instance()->setMyUid(((myLoginData*)userdata)->user);

    },data);


  std::cout<<"end async"<<std::endl;
}

void LoginControl::showMain()
{
  PageControl::ShowMain();
}

LoginControl::LoginControl()
{
  qDebug()<<"init ";
}
